﻿using SaysayProject.Data;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using SaysayProject.Models;
namespace SaysayProject.Data
{
    // public class  Default
    //{
    //    public  object up() {
    //        var obj = new
    //        {
    //            CreatedAt = DateTime.Now,
    //            UpdatedAt = DateTime.Now,
    //            Version = 0
    //        };

    //        return obj;
    //    }

    //}

    //初始化数据
    public class SayDemoDbInitlizer : DropCreateDatabaseAlways<CmsDb>
    {
        protected override void Seed(CmsDb db)
        {
            //向Users模型插入数据
            db.Users.Add(new Users
            {
                Username = "志浩",
                Password = "123456",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0

            });
            //向Users模型插入数据
            db.Users.Add(new Users
            {
                Username = "admin",
                Password = "123456",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            //向Messages模型插入数据
            db.Messages.Add(new Messages
            {
                FromUserId = 1,
                Content = "今天好大的雨",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            //向Messages模型插入数据
            db.Messages.Add(new Messages
            {
                FromUserId = 2,
                Content = "我不是耀杨",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            //向Comments模型插入数据
            db.Comments.Add(new Comments
            {
                MsgId = 1,
                FromUserId = 2,
                Content = "hello",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            //向Comments模型插入数据
            db.Comments.Add(new Comments
            {
                MsgId = 2,
                FromUserId = 1,
                Content = "那你是谁",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });

            db.SaveChanges();
            base.Seed(db);
        }
    }
}